from selenium.webdriver.common.by import By
from base.base_action import BaseAction


# 培训分类页面
class TrainSortPage(BaseAction):

    # 培训管理按钮
    train_manage_btn = By.XPATH, "//span[text()='培训管理']"

    # 培训规划按钮
    train_plan_btn = By.XPATH, "//span[text()='培训规划']"

    # 搜索分类
    train_sort_btn = By.XPATH, "//span[text()='培训分类']"

    # 搜素分类名称
    first_search = By.XPATH, "//input[@placeholder='搜索分类']"

    # 第二个搜索框
    second_search = By.XPATH, "//input[@placeholder='搜索分类名称']"

    # 新建按钮
    new_btn = By.XPATH, "//span[contains(text(),'导出数据')]/ancestor::div[3]/div/button"

    # 分类名称输入框
    sort_name_input = By.XPATH, "//textarea"

    # 确定按钮
    determine_btn = "document.getElementsByClassName('el-button el-button--primary')[0].click();"

    # 上下移动按钮
    move_up_btn = "document.getElementsByClassName('operate-style')[3].click();"

    move_down_btn = "document.getElementsByClassName('operate-style')[4].click();"

    # 删除按钮
    remove_btn = "document.getElementsByClassName('operate-style')[1].click();"

    # 删除弹窗的确定按钮
    determine1_btn = By.XPATH, "/html/body/div[2]/div/div[3]/button[2]"

    # 编辑按钮
    edit_btn = "document.getElementsByClassName('operate-style')[0].click();"

    # 分类名称输入框
    sort_name_input1 = By.XPATH, "//input[@placeholder='请输入分类名称']"

    # 点击培训管理
    def click_train_manage_btn(self):
        return self.click(self.train_manage_btn)

    # 在第一个搜索框输入内容进行查询
    def input_content_first_search(self, content):
        return self.input(self.first_search, content)

    # 在第二个搜索框输入内容进行查询
    def input_content_second_search(self, content):
        return self.input(self.second_search, content)

    # 点击新建
    def click_new_btn(self):
        return self.click(self.new_btn)

    # 输入分类名称
    def input_sort_name(self, content):
        return self.input(self.sort_name_input, content)

    # 点击确定按钮
    def click_determine_btn(self):
        return self.execute_js(self.determine_btn)

    # 点击分类名称进入编辑
    def click_sort_name_btn(self):
        return self.execute_js(self.edit_btn)

    # 清空分类名称
    def clear_sort_name(self):
        return self.clear(self.sort_name_input1)

    # 输入名称
    def input_sort_name1(self, content):
        return self.input(self.sort_name_input1, content)

    # 点击上移按钮
    def click_move_up_btn(self):
        return self.execute_js(self.move_up_btn)

    # 点击下移按钮
    def click_move_down_btn(self):
        return self.execute_js(self.move_down_btn)

    # 点击删除按钮
    def click_remove_btn(self):
        return self.execute_js(self.remove_btn)

    # 点击确定按钮
    def click_determine1_btn(self):
        return self.click(self.determine1_btn)






